From 6d04183c5d6529840e7ee22a161a47bfc58b5303 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 26 Jul 2015 02:04:48 -0400 Subject: [PATCH] quartz: Check if a drag ends inside a known window If a drag ends inside a known window, set the dest_window field in the drag context. This information is needed to implemented notebook tab dragging. https://bugzilla.gnome.org/show_bug.cgi?id=752638 --- gdk/quartz/GdkQuartzNSWindow.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c index 87206ca990..848ed50daf 100644 --- a/gdk/quartz/GdkQuartzNSWindow.c +++ b/gdk/quartz/GdkQuartzNSWindow.c @@ -656,6 +656,7 @@ update_context_from_dragging_info (id sender) - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation { GdkEvent *event; + GdkScreen *screen; g_assert (_gdk_quartz_drag_source_context != NULL); @@ -664,6 +665,33 @@ update_context_from_dragging_info (id sender) event->dnd.send_event = FALSE; event->dnd.context = g_object_ref (_gdk_quartz_drag_source_context); + screen = gdk_window_get_screen (event.dnd.window); + + if (screen) + { + GList* windows, *list; + gint gx, gy; + + event.dnd.context->dest_window = NULL; + + windows = gdk_screen_get_toplevel_windows (screen); + _gdk_quartz_window_nspoint_to_gdk_xy (aPoint, &gx, &gy); + + for (list = windows; list; list = list->next) + { + GdkWindow* win = (GdkWindow*) list->data; + gint wx, wy; + gint ww, wh; + + gdk_window_get_root_origin (win, &wx, &wy); + ww = gdk_window_get_width (win); + wh = gdk_window_get_height (win); + + if (gx > wx && gy > wy && gx <= wx + ww && gy <= wy + wh) + event.dnd.context->dest_window = win; + } + } + gdk_event_set_device (event, gdk_drag_context_get_device (_gdk_quartz_drag_source_context)); -- 2.30.2